package shujia.day15;

/*
    加入线程 join
    当执行join方法的线程，其他线程需要等待该线程执行完毕后才可以执行。
 */

class MyThread4 extends Thread{
    public MyThread4() {
    }

    public MyThread4(String name) {
        super(name);
    }

    @Override
    public void run() {
        for(int i=1;i<=200;i++){
            System.out.println(getName()+" - "+i);
        }
    }
}
public class ThreadJoinDemo1 {
    public static void main(String[] args) {
        MyThread4 t1 = new MyThread4("张成阳");
        MyThread4 t2 = new MyThread4("方直");
        MyThread4 t3 = new MyThread4("杨浩东");

        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t2.start();
        t3.start();
    }
}
